package com.zhw.controller;

import com.zhw.pojo.Result;
import com.zhw.pojo.entry.CustomerReprieve;
import com.zhw.service.CustomerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("customerReprieve")
public class CustomerReprieveController {

    @Autowired
    CustomerService customerService;

    @GetMapping("getByReprieveByLossID")
    public Result getByReprieveByLossID(Integer id){
        log.info("查询ID：{}的客户暂缓信息",id);
        List<CustomerReprieve> list=customerService.getReprieveByLossID(id);
        return Result.success(list);
    }

    @PostMapping("addReprieve")
    public Result add(@RequestBody CustomerReprieve customerReprieve){
        log.info("添加补救措施：{}",customerReprieve);
        customerService.add(customerReprieve);
        return Result.success();
    }


    @GetMapping("getReprieveByID")
    public Result getReprieveByID(Integer id){
        log.info("根据ID查询当前补救措施：{}",id);
        CustomerReprieve customerReprieve=customerService.getReprieveByID(id);
        return Result.success(customerReprieve);
    }


    @PutMapping("updateReprieve")
    public Result updateReprieve(@RequestBody CustomerReprieve customerReprieve){
        log.info("修改当前补救措施：{}",customerReprieve);
        customerService.updateReprieve(customerReprieve);

        return Result.success();
    }


    @DeleteMapping("deleteReprieveByID")
    public Result deleteReprieveByID(Integer id){
        log.info("删除措施ID：{}",id);
        customerService.deleteReprieveByID(id);
        return Result.success();

    }



}
